define(function(require, exports, module) {
	/*加载jquery*/
	var $ = require("../modules/jquery/jquery.js")
	exports.init = function() {
		var MenuInfo = {
			data() {
				return {
					mainStyle: {
						height: 0,
					},
					keyword: '大龙虾',
					parentNode: [],
					filterText:'',
					previousMenu:[],
					data2: [{
						id: 1,
						label: '一级 1',
						children: [{
							id: 4,
							label: '二级 1-1',
							children: [{
								id: 9,
								label: '三级 1-1-1'
							}, {
								id: 10,
								label: '三级 1-1-2'
							}]
						}]
					}, {
						id: 2,
						label: '一级 2',
						children: [{
							id: 5,
							label: '二级 2-1'
						}, {
							id: 6,
							label: '二级 2-2'
						}]
					}, {
						id: 3,
						label: '一级 3',
						children: [{
							id: 7,
							label: '二级 3-1'
						}, {
							id: 8,
							label: '二级 3-2'
						}]
					}],
					options: [{
						value: 'zhinan',
						label: '指南',
						children: [{
							value: 'shejiyuanze',
							label: '设计原则',
							children: [{
								value: 'yizhi',
								label: '一致'
							}, {
								value: 'fankui',
								label: '反馈'
							}, {
								value: 'xiaolv',
								label: '效率'
							}, {
								value: 'kekong',
								label: '可控'
							}]
						}, {
							value: 'daohang',
							label: '导航',
							children: [{
								value: 'cexiangdaohang',
								label: '侧向导航'
							}, {
								value: 'dingbudaohang',
								label: '顶部导航'
							}]
						}]
					}, {
						value: 'zujian',
						label: '组件',
						children: [{
							value: 'basic',
							label: 'Basic',
							children: [{
								value: 'layout',
								label: 'Layout 布局'
							}, {
								value: 'color',
								label: 'Color 色彩'
							}, {
								value: 'typography',
								label: 'Typography 字体'
							}, {
								value: 'icon',
								label: 'Icon 图标'
							}, {
								value: 'button',
								label: 'Button 按钮'
							}]
						}]
					}, {
						value: 'ziyuan',
						label: '资源',
						children: [{
							value: 'axure',
							label: 'Axure Components'
						}, {
							value: 'sketch',
							label: 'Sketch Templates'
						}, {
							value: 'jiaohu',
							label: '组件交互文档'
						}]
					}],
					defaultProps: {
						children: 'children',
						label: 'label'
					},
					addMenuDialogVisable: false
				};
			},
			methods: {
				/**
				 * 过滤菜单
				 * @param {Object} value
				 * @param {Object} data
				 */
				filterNode:function(value,data){
					if(!value) return true;
					return data.label.indexOf(value) !== -1;
				},
				/**
				 * 查询父菜单
				 */
				selectPreviousMenu:function(){
					var _this = this;
					$.ajax({
						type:"get",
						url:"/hz-console/menu/getHzMenu.do",
						async:true,
						dataType:"json",
						success:function (data) {
							_this.previousMenu = data;
						},
						error:function (ex) {
							alert(ex);
						}
					});
				},
				/**
				 * 查询tree菜单
				 */
				queryTreeMenu:function(){
					var _this = this;
					debugger
					$.ajax({
						type:"get",
						url:"/hz-console/menu/getHzTreeMenu.do",
						async:true,
						dataType:"json",
						success:function (data) {
							_this.previousMenu = data;
							console.log(_this.previousMenu);
						}
					});
				},
				handleNodeClick(data) {
					console.log(data);
				},
				handleChange(value) {
					console.log(value);
				},
				openAddMenuDialog: function() {
					this.addMenuDialogVisable = true;
				},
				openDelMenuMesbox: function() {
					this.$confirm('此操作将永久删除选中菜单, 是否继续?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning',
						center: true
					}).then(() => {
						this.$message({
							type: 'success',
							message: '删除成功!'
						});
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '已取消删除'
						});
					});
				},
			},
			watch:{
				filterText(val){
					this.$refs.tree2.filter(val);
				}
			},
			
			created: function() {
				this.mainStyle.height = $(window).height() + 1000 + 'px';
				this.queryTreeMenu();
			},

		}
		var Ctor = Vue.extend(MenuInfo);
		new Ctor().$mount('#em');
	}
})